import React, { Component } from 'react';
import './goodsList.scss'
import { index_goodlist } from '../utils/api'
class GoodsList extends Component {
    constructor(props){
        super(props);
        this.state = {
            currentIndex:0,
            goodsList:[]

        }
    }
    componentDidMount(){
        index_goodlist({count:9}).then((res)=>{
            console.log(res.data);
            this.setState({
                goodsList:res.data.list
            })
        })
    }
    handleClick(index){
        this.setState({
            currentIndex:index
        })
    }
    render() {
        return (
            <div className="goods">
                <div className="banner">
                    <span className='p1'>今日值得买</span>
                    <span className='p2'>MORE ▷</span>
                </div>
                <div className='goodsList'>
                    {
                        this.state.goodsList.map((item,index)=>{
                            return(
                                <div className="item" key={index}>
                                    <img src={item.pic} alt="" />
                                    <p className='name'>{item.name}</p>
                                    <p className="price">抢购价：{parseInt(item.salesPrice.value)}</p>
                                    {/* <div className="nowPrice"></div> */}
                                </div>
                            )
                        })
                    }
                </div>
               </div>
        );
    }
}

export default GoodsList;